﻿<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>使用GD库函数</title>
</head>
<body>
<?php
    // File and new size
	$filename = '1.jpg';  
	$percent = 1.2;
	header('Content-type: image/jpeg');
	// Get new sizes   宽度和高度都变为原来的50%
	list($width, $height) = getimagesize($filename);
	$newwidth = $width * $percent;  
	$newheight = $height * $percent;
	// Load
	$thumb = imagecreatetruecolor($newwidth, $newheight);
	$source = imagecreatefromjpeg($filename);
	// Resize
	imagecopyresized($thumb, $source, 100, 200, 200, 300, $newwidth, $newheight, $width, $height);
	// Output
	ob_clean();  
	flush();
	imagejpeg($thumb);
	imagedestroy($thumb);
?>
</body>
</html>